package me.drakeet.meizhi.util;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by ThinkPad on 2017/5/11.
 */

public class MySharedPrefs {

    public void write(Context context,String key,String value)
    {
        SharedPreferences sharedPreferences= context.getSharedPreferences("test",
                Activity.MODE_PRIVATE);
        //实例化SharedPreferences.Editor对象
        SharedPreferences.Editor editor = sharedPreferences.edit();
        //用putString的方法保存数据
        editor.putString(key, value);
        //提交当前数据
        editor.apply();
    }
    public String  read(Context context,String key)
    {
        SharedPreferences sharedPreferences= context.getSharedPreferences("test",
                Activity.MODE_PRIVATE);
        return sharedPreferences.getString(key,"");
    }
}
